/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package azhar.engine;

import azhar.view.Main;
import javax.swing.JOptionPane;
import org.smslib.*;
import org.smslib.Message.*;

/**
 *
 * @author Al-Insan
 */
public class InboundNotification implements IInboundMessageNotification {

    private Main main;

    public InboundNotification(Main m) {
        main = m;
    }

    public void process(AGateway gateway, MessageTypes msgType, InboundMessage msg) {
        if (msgType == MessageTypes.INBOUND) {
//            System.out.println(">>> say New Inbound message detected from Gateway: " + gateway.getGatewayId());
//            System.out.println(msg);
            main.readMessage(msg);
        } else if (msgType == MessageTypes.STATUSREPORT) {
            System.out.println(">>> New Inbound Status Report message detected from Gateway: " + gateway.getGatewayId());
        }
        try {
            gateway.deleteMessage(msg);
        } catch (Exception ex) {
            JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE);
        }
    }
}
